#include <iostream>
#include <cstring>
#include "user.h"
using namespace std;
//定义结构体
void printH();
void print(struct Books book);
void print(struct Books *book);
void print(struct User *user);

struct Books{
    char title[50];
    char author[50];
    char subject[100];
    int book_id;
} book;
//使用typedef 定义
/*typedef struct User{
    string user_name;
    string real_name;
    string gender;
    string user_id;
}User;*/

int main() {
    struct Books book1;

    //Book1
    strcpy(book1.title,"Learn C++ Programing");
    strcpy(book1.author,"styx");
    strcpy(book1.subject,"C++ Programing");
    book1.book_id=100001;

    User user;
    user.gender="男";
    user.real_name="张小贱";
    user.user_name="styx";
    user.user_id="1230001";

   /* cout<<"Book 1 book_id:"<<book1.book_id<<endl;
    cout<<"Book 1 author:"<<book1.author<<endl;
    cout<<"Book 1 subject:"<<book1.subject<<endl;
    cout<<"Book 1 title:"<<book1.title<<endl;*/
    print(book1);
    //使用指针
    printH();
    print(&book1);
    printH();
    print(&user);
    return 0;
}
//使用结构体入参
void print(struct Books book){
    cout<<"Book 1 book_id:"<<book.book_id<<endl;
    cout<<"Book 1 author:"<<book.author<<endl;
    cout<<"Book 1 subject:"<<book.subject<<endl;
    cout<<"Book 1 title:"<<book.title<<endl;
}
void printH(){
    cout<<"-------------------------------"<<endl;
}
//使用指针的结构
void print(struct Books *book){
    cout<<"Book 1 book_id:"<<book->book_id<<endl;
    cout<<"Book 1 author:"<<book->author<<endl;
    cout<<"Book 1 subject:"<<book->subject<<endl;
    cout<<"Book 1 title:"<<book->title<<endl;
}
//使用typedef
/*void print(User *user){
    cout<<"user_id:"<<user->user_id<<endl;
    cout<<"user_name:"<<user->user_name<<endl;
    cout<<"real_name:"<<user->real_name<<endl;
    cout<<"gender:"<<user->gender<<endl;
}*/

